package com.tjsinfo.tjsoa.documentationflow.xingzhengfawen.action;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.common.SessionUser;
import com.tjsinfo.tjsoa.documentationflow.xingzhengfawen.bo.IFaWenAdminBO;
import com.tjsinfo.tjsoa.documentationflow.xingzhengfawen.bo.IWenTypeBO;
import com.tjsinfo.tjsoa.documentationflow.xingzhengfawen.vo.FaWenInfo;
import com.tjsinfo.tjsoa.documentationflow.xingzhengfawen.vo.MainType;
import com.tjsinfo.tjsoa.documentationflow.xingzhengfawen.vo.SubTypeInfo;
import com.tjsinfo.tjsoa.system.bo.ISystemUserBo;

/**
 * 发文管理
 * @author Administrator
 *
 */
public class FaWenAdminAction extends Action{
	private IFaWenAdminBO faWenAdminBO;
	private IWenTypeBO wenTypeBO;
	private ISystemUserBo systemUserBo;
	
	
	
	public ISystemUserBo getSystemUserBo() {
		return systemUserBo;
	}


	public void setSystemUserBo(ISystemUserBo systemUserBo) {
		this.systemUserBo = systemUserBo;
	}


	public IWenTypeBO getWenTypeBO() {
		return wenTypeBO;
	}
	
	
	public void setWenTypeBO(IWenTypeBO wenTypeBO) {
		this.wenTypeBO = wenTypeBO;
	}
	
	public IFaWenAdminBO getFaWenAdminBO() {
		return faWenAdminBO;
	}


	public void setFaWenAdminBO(IFaWenAdminBO faWenAdminBO) {
		this.faWenAdminBO = faWenAdminBO;
	}




	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		Integer userid = SessionUser.getUserId(request); 
		
		List<FaWenInfo> listall = faWenAdminBO.selectFaWenAll(userid);
		List<FaWenInfo> qianFaList = new ArrayList<FaWenInfo>();
		List<FaWenInfo> fenguanshenyueList =  new ArrayList<FaWenInfo>();
		List<FaWenInfo> hegaoList =  new ArrayList<FaWenInfo>();
		List<FaWenInfo> tuihuiList =  new ArrayList<FaWenInfo>();
		List<FaWenInfo> banGongShiZhuRenFuHeList =   new ArrayList<FaWenInfo>();
		List<FaWenInfo> dangBanZhuRenFuHeList =   new ArrayList<FaWenInfo>();
		List<FaWenInfo> bumenhuiqianList =   new ArrayList<FaWenInfo>();
		List<FaWenInfo> taohongList =  new ArrayList<FaWenInfo>();
		List<FaWenInfo> gaizhangList =   new ArrayList<FaWenInfo>();
		List<FaWenInfo> taohongxiugaiList =   new ArrayList<FaWenInfo>();
		List<FaWenInfo> fawendengjiList =   new ArrayList<FaWenInfo>();
		List<FaWenInfo> fengfaList =   new ArrayList<FaWenInfo>();
		
		for(int i=0; i<listall.size();i++){
			FaWenInfo faweninfo = listall.get(i);
			String huanjie=faweninfo.getNodename();
			if("签发".equals(huanjie)){
				qianFaList.add(faweninfo);
			}else if("分管领导审阅".equals(huanjie)){
				fenguanshenyueList.add(faweninfo);
			}else if("部门审核".equals(huanjie)){
				hegaoList.add(faweninfo);
			}else if("拟稿人修改内容".equals(huanjie)){
				tuihuiList.add(faweninfo);
			}else if("办公室主任复核".equals(huanjie)){
				banGongShiZhuRenFuHeList.add(faweninfo);
			}else if("党办主任复核".equals(huanjie)){
				dangBanZhuRenFuHeList.add(faweninfo);
			}else if("部门主管会签".equals(huanjie)){
				bumenhuiqianList.add(faweninfo);
			}else if("校对套红".equals(huanjie)){
				taohongList.add(faweninfo);
			}else if("盖章".equals(huanjie)){
				gaizhangList.add(faweninfo);
			}else if("套红修改".equals(huanjie)){
				taohongxiugaiList.add(faweninfo);
			}else if("发文登记".equals(huanjie)){
				fawendengjiList.add(faweninfo);
			}else if("封发".equals(huanjie)){
				fengfaList.add(faweninfo);
			}
		}
		
		List<FaWenInfo> banlizhongList =  new ArrayList<FaWenInfo>();
		
	//	if(systemUserBo.isUserPost(userid, "发文办理追踪人")){
			banlizhongList = faWenAdminBO.selectFaWenByBanLiZhong(userid);
	//	}else{
	//		banlizhongList = faWenAdminBO.selectFaWenNigaoren(userid);
	//	}
		
		
		request.setAttribute("qianFaList", qianFaList);
		request.setAttribute("fenguanshenyueList", fenguanshenyueList);
		request.setAttribute("hegaoList", hegaoList);
		request.setAttribute("banlizhongList", banlizhongList);
		request.setAttribute("tuihuiList", tuihuiList);
		request.setAttribute("banGongShiZhuRenFuHeList", banGongShiZhuRenFuHeList);
		request.setAttribute("dangBanZhuRenFuHeList", dangBanZhuRenFuHeList);
		request.setAttribute("bumenhuiqianList", bumenhuiqianList);
		request.setAttribute("taohongList", taohongList);
		request.setAttribute("taohongxiugaiList", taohongxiugaiList);
		request.setAttribute("gaizhangList", gaizhangList);
		request.setAttribute("fawendengjiList", fawendengjiList);
		request.setAttribute("fengfaList", fengfaList);
		List<MainType> maintypeList =  wenTypeBO.selectMainType();
		request.setAttribute("maintypeList", maintypeList);
		return mapping.findForward("ok");
		
				
	}
	
}
